<%--
  Created by IntelliJ IDEA.
  User: KaiFaBu010
  Date: 2017-12-12
  Time: 19:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <jsp:include page="/WEB-INF/jsp/head.jsp">
        <jsp:param value="新增游戏账号" name="pageTitle"/>
    </jsp:include>
    <script src="/js/common.js"></script>
</head>
<body>
<div id="new-gameAccount-div" title="新增游戏账号" >
    <div style="padding:10px">
        <form id="new-gameAccount" class="easyui-panel" style="width:100%;height:100%;">
            <table style="width:100%;height:100%;">
                <tr>
                    <td>游戏账号名字：</td>
                    <td>
                        <input class="easyui-textbox" type="text" id="accountnum" name="accountnum" style="width: 150px"
                               data-options="required:true"/></td>

                    </td>
                    <td>所属游戏：</td>
                    <td>
                        <input type="text" name="thegame" id="thegame" hidden="hidden" readonly="readonly"/>
                        <select class=" yj-select" style="width: 100px" type="text" id="gid"  name="gid" data-options="required:true" >
                        </select>
                    </td>

                </tr>
                <tr>
                    <td>初始分数：</td>
                    <td><input id="proportion" class="easyui-numberbox" type="text" name="initialscore"
                               data-options="min:0,precision:2,required:true" groupSeparator=","
                               style="width: 150px;text-align:right" /></td>
                </tr>
            </table>

        </form>
        <div style="margin-top:15px;padding-bottom: 15px;">
            <button id="new-gameAccount-submit" class="easyui-linkbutton" ><i class="fa fa-save"></i>&nbsp;保存</button>
            <button id="new-game-off" class="easyui-linkbutton"><i class="fa fa-save"></i>&nbsp;取消</button>
        </div>



    </div>
</div>

<script>


    //关联游戏显示
    $("#gid").combobox({
        url: "/games/getAllNo",
        valueField: "gid",
        textField: "gname",
        editable: false
    });

    $("#gid").change(function () {
        var thegame = $("#gid").textField;
        $('#thegame').val(thegame);
    });


    $('#new-game-off').click(function (e) {
        e.preventDefault();
        e.stopPropagation();
        window.location.href='/gameAccount/home';
    });



    //新增游戏保存
    $('#new-gameAccount-submit').click(function (e) {
        e.preventDefault();
        e.stopPropagation();
        var isOk = false;
        isOk = $("#new-gameAccount").form('enableValidation').form('validate');
        if(isOk){
            var form = $("#new-gameAccount").serializeArray();
            var tojson = formtojson(form);
            $.ajax({
                type: "POST",
                url: "/gameAccount/insetNewGameAccount",
                data: {
                    "datalist": tojson
                },
                dataType: "json",
                success: function (data) {
                    $.messager.alert('提示信息', data["msg"], 'warning', function () {
                        //跳转地址
                        location.href = "/gameAccount/home";
                    });

                }
            });
        }else{
            $.messager.show({
                title: '新增游戏',
                msg: "必须输入完整",
                timeout: 5000,
                showType: 'slide'
            });
            return
        }

    });



</script>

</body>
</html>
